﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

using CSF.Customers.Data;
using CSF.Customers.BLL;
using CSF.Customers.Service;
using CSF.Security.Data;
using CSF.BusinessCore.Service;
using CSF.Security.BLL;


namespace CSF.Service.Accounts
{
    // 注意: 使用“重构”菜单上的“重命名”命令，可以同时更改代码、svc 和配置文件中的类名“CustomerSvc”。
    [ErrorHandleBehavior]
    public class CustomerSvc : ICustomerSvc
    {

        #region ICustomerSvc 成员

        public List<Security.Data.UserAccount> GetCustomerUsers(int customerId)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetCustomerUsers(customerId);
        }

        public bool JoinCustomerUser(int customerId, int userId, string createBy)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.JoinCustomerUser(customerId, userId, createBy);
        }

        public List<Customers.Data.Customer> GetByUser(int userId)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetByUser(userId);
        }

        public bool ApproveBatch(IEnumerable<int> customerIds, bool isApproved, string approveComment, string approveBy)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.ApproveBatch(customerIds, isApproved, approveComment, approveBy);
        }

        public List<Customers.Data.Customer> GetByApprovalStatus(Customers.Data.ApprovalStatus status)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetByApprovalStatus(status);
        }

        public List<Customers.Data.Customer> GetChildren(int companyId)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetChildren(companyId);
        }

        #endregion

        #region IDataIdKeyService<Customer> 成员

        public Customers.Data.Customer GetOneById(int id)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetOneById(id);
        }

        public bool UpdateById(Customers.Data.Customer t, int id)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.UpdateById(t, id);
        }

        public bool DeleteOneById(int id)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.DeleteOneById(id);
        }

        #endregion

        #region IDataEntityService<Customer> 成员

        public List<Customers.Data.Customer> GetAll()
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetAll();
        }

        public int Insert(Customers.Data.Customer entity)
        {
            CustomerBLL bll = new CustomerBLL();
             bll.Insert(entity);
             return entity.Id;
        }

        #endregion

        #region IDataConfigService<Customer> 成员

        public Customers.Data.Customer GetOneByCode(string code)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetOneByCode(code);
        }

        public List<Customers.Data.Customer> GetEnable()
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetEnable();
        }

        public List<Customers.Data.Customer> GetDisable()
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetDisable();
        }

        public List<Customers.Data.Customer> GetStartsWith(string keyword, bool isDisable)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.GetStartsWith(keyword, isDisable);
        }

        public bool Enable(Customers.Data.Customer t)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.Enable(t);
        }

        public bool Disable(Customers.Data.Customer t)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.Enable(t);
        }

        #endregion

        #region IDataIdKeyService<Customer> 成员


        public int DeleteById(IEnumerable<int> ids)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.DeleteById(ids);
        }

        #endregion

        #region ICustomerSvc 成员


        public int RegisterWithUser(UserAccount userAccount, Customer customer, int applicationId)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.RegisterWithUser(userAccount, customer, applicationId);
        }

        public bool UpdateBySelf(Customer customer, string modifyBy)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.UpdateBySelf(customer, modifyBy);
        }

        public int InsertCustomerUser(UserAccount entity, int CustomerId, string createBy)
        {
            CustomerBLL bll = new CustomerBLL();            
            return bll.InsertCustomerUser(entity, CustomerId, createBy);
        }

        public bool UpdateByIdByUser(UserAccount entity, int CustomerId, string createBy)
        {
            CustomerBLL bll = new CustomerBLL();
            return bll.UpdateByIdByUser(entity, CustomerId, createBy);
        }
        #endregion

    }
}
